<template>
  <div class="ele-body" v-loading="loading">
    <div class="info-content">
      <el-card class="content-left" shadow="never">
        <div class="left-top">
          <div>基本信息：</div>
        </div>
        <div class="left-bottom-info">
          <div>信息来源： {{info.project_number?'项目反馈':'工单反馈'}} <span @click="toSource" style="cursor: pointer;color: rgb(37, 99, 235)">({{info.project_number||info.wo_number}})</span></div>
          <div>订单号： {{ info.order_number }}</div>
          <div>质量问题： <span>{{ info.is_quality?'是':'否' }}</span></div>
          <div v-if="info.is_quality">设备名称： {{ info.product_name }}</div>
          <div v-if="info.is_quality">设备编号：{{info.product_number}}</div>
          <div v-if="info.is_quality">异常数量： <span>{{ info.quantity }}</span></div>
          <div v-if="info.is_quality">生产基地： {{ info.production_base }}</div>
          <div v-if="info.is_quality">设备开机时间： {{ info.boot_time }}</div>
          <div v-if="info.is_quality">设备运行时间： {{ info.run_time?info.run_time+'天':'' }}</div>
          <div v-if="info.is_quality">质保开始时间： {{ info.warranty_start }}</div>
          <div v-if="info.is_quality">是否退回： {{ info.is_return?'是':'否' }}</div>
          <div>问题等级： <span>{{ info.question_level }}</span></div>
          <div>问题归类： <span>{{ info.question_type }}</span></div>
          <div>更换配件：<span>{{ info.bom_replace?'是':'否' }}</span></div>
          <div>反馈人： <span>{{ info.user_name  }}</span></div>
          <div>客户信息： {{ info.customer_name }}</div>
          <div>区域经理： {{ info.manager_name }}</div>
          <div>反馈时间： {{ info.create_time }}</div>

          <div>反馈日志： {{  info.histories?((info.histories)[info.histories.length-1].comment.user_name) +(info.histories)[info.histories.length-1].comment.comment:''}}</div>
        </div>

      </el-card>
      <el-card class="right" shadow="never">
        <el-tabs v-model="activeName" >
          <el-tab-pane label="质量反馈" name="first">
            <el-form ref="form" :model="info" label-width="120px" label-position="left">
              <el-form-item label="问题描述：">
                <el-input type="textarea" :rows="4" v-model="info.description" maxlength="200" show-word-limit disabled></el-input>
              </el-form-item>
              <el-form-item label="原因分析：">
                <el-input type="textarea" :rows="4" v-model="info.reason" maxlength="200" show-word-limit disabled></el-input>
              </el-form-item>
              <el-form-item label="临时措施：">
                <el-input type="textarea" :rows="4" v-model="info.measure_temp" maxlength="200" show-word-limit disabled></el-input>
              </el-form-item>
              <el-form-item label="建议处理意见：">
                <el-input type="textarea" :rows="4" v-model="info.suggestion" maxlength="200" show-word-limit disabled></el-input>
              </el-form-item>
              <el-form-item label="现场图片：">
                <div style="overflow: auto;flex: 1;" >
                  <el-image style="width: 60px; height: 60px;border-radius: 3px"  v-for="item in info.images" :src="item" :key="item" :preview-src-list="[item]" >
                    <div  slot="error" class="image-slot">
                      <i class="el-icon-picture"></i>
                    </div>
                  </el-image>
                </div>
              </el-form-item>
              <!--          <div class="auditWrap"><el-button type="primary" @click="audit">审核</el-button></div>-->

            </el-form>
          </el-tab-pane>
          <el-tab-pane label="审核意见" name="second">
            <el-row>
              <el-col :span="12">
                <el-row>
                  <el-col :span="12">
                    区域经理审核意见:
                  </el-col>
                  <el-col :span="12" >
                    <span style="color: #6ab7ff;cursor: pointer" @click="toManager" v-if="this.info.quantity_update_time">查看</span>
                    <span v-else>暂无</span>
                  </el-col>
                </el-row>
              </el-col>
            </el-row>
            <el-row style="margin-top: 20px">
              <el-col :span="12">
                <el-row>
                  <el-col :span="12">
                    区域经理审核时间:
                  </el-col>
                  <el-col :span="12">
                    {{this.info.manager_action_time?this.info.manager_action_time:'-  -'}}
                  </el-col>
                </el-row>
              </el-col>
            </el-row>
            <el-row style="margin-top: 20px">
              <el-col :span="12">
                <el-row>
                  <el-col :span="12">
                    品质工程师处理意见:
                  </el-col>
                  <el-col :span="12">
                    <el-col  >
                      <span style="color: #6ab7ff;cursor: pointer" @click="toQuantity" v-if="this.info.quantity_update_time">查看</span>
                      <span v-else>暂无</span>
                    </el-col>
                  </el-col>
                </el-row>
              </el-col>
            </el-row>
            <el-row style="margin-top: 20px">
              <el-col :span="12">
                <el-row>
                  <el-col :span="12">
                    品质工程师处理时间:
                  </el-col>
                  <el-col :span="12">
                    {{this.info.quantity_update_time?this.info.quantity_update_time:'-  -'}}
                  </el-col>
                </el-row>
              </el-col>
            </el-row>
            <el-row style="margin-top: 20px">
              <el-col :span="12">
                <el-row>
                  <el-col :span="12">
                    反馈者处理意见:
                  </el-col>
                  <el-col :span="12">
                    {{this.info.resolved?'已解决':'未解决'}}
                  </el-col>
                </el-row>
              </el-col>
            </el-row>
            <el-row style="margin-top: 20px">
              <el-col :span="12">
                <el-row>
                  <el-col :span="12">
                    关闭时间:
                  </el-col>
                  <el-col :span="12">
                    {{this.info.close_time?this.info.close_time:'-  -'}}
                  </el-col>
                </el-row>
              </el-col>
            </el-row>
          </el-tab-pane>
        </el-tabs>

      </el-card>
      <Manager_opinion :visible.sync="manager_visible" :info="info"></Manager_opinion>
      <quantityOpinion :visible.sync="quantity_visible" :info="info"></quantityOpinion>
      <Audit ></Audit>
    </div>
  </div>
</template>

<script>
import Audit from "./components/audit.vue"
import {mapGetters} from "vuex";
import Manager_opinion from "@/views/qualityFeedback/qualityFeedback/info/components/manager_opinion.vue";
import quantityOpinion   from "@/views/qualityFeedback/qualityFeedback/info/components/quantity-opinion.vue";


export default {
  components: {Audit,Manager_opinion,quantityOpinion},
  data() {
    return {
      activeName:'first',
      loading: false,
      manager_visible:false,
      quantity_visible:false,
      id: null,
      info: {},
      logs: [],
    }
  },
  computed: {
    ...mapGetters(["permission"]),
  },
  mounted() {
    this.init()
  },
  created() {
    this.id = this.$route.query.id;
  },
  watch:{

  },
  methods: {
    init() {
      this.loading = true
      this.$http.get(`/question_feedback/${this.id}`,).then(res => {
        this.loading = false;
        if (res.data.code === 0) {
          this.info = res.data.data
        } else {
          this.$message.error(res.data.msg);
        }
      })
    },
    toSource(){
      if(this.info.project_id){
        this.$router.push({path:`/project/projectList/info?id=${this.info.project_id}`})
      }else{
        this.$router.push({path:`/workTickets/workTickets/info?id=${this.info.wo_id}`})
      }
    },
    audit(){
        this.visible=true
    },
    toManager(){
      this.manager_visible=true
    },
    toQuantity(){
      this.quantity_visible=true
    }
  }
}
</script>

<style lang="scss" scoped>


.work_info {
  width: 96%;
  margin: 50px auto 0;
}


.top {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  justify-content: space-between;
}

.bottom {
  display: flex;
  height: 100%;
  align-items: center;

  .list {
    width: 108px;
    height: 35px;
    text-align: center;
    line-height: 38px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, .05), 0 2px 6px 0 rgba(0, 0, 0, .045);
    background-color: var(--color-primary-1);
    color: var(--color-primary);
    position: relative;
    margin: 0 15px 0 10px;
    letter-spacing: 5px;
    font-weight: bold;
    border-left: 4px solid var(--color-primary);
    border-radius: 4px 2px 2px 4px;

    &::after {
      content: " ";
      width: 0;
      height: 0;
      position: absolute;
      top: -1px;
      right: -7px;
      display: inline-block;
      border-color: transparent transparent transparent var(--color-primary-1);
      border-style: solid;
      border-width: 18px 0 18px 8px;
    }
  }
}


.info-content {
  height: calc(100vh - 150px);
  margin-top: 15px;
  display: flex;
  flex: 1;
  justify-content: space-between;

  .el-card + .el-card {
    margin-top: 0;
  }

  .content-left {
    width: 30%;
    box-sizing: border-box;
    overflow: auto;

    .left-top {
      font-size: 14px;
      color: #000000;
      font-weight: 600;
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding-bottom: 10px;
      border-bottom: 2px solid #eeeeee;
      box-sizing: border-box;
    }

    .left-bottom-info {
      font-size: 14px;

      div {
        padding: 10px 5px;
      }
    }
  }
  .el-tab-pane{
    box-sizing: border-box;
    padding: 20px;
  }
  .right {
    width: 68%;
    margin-left: 15px;
    flex: 1;
    overflow: auto;

    .right-top {
      font-size: 14px;
      color: #005ee0;
      font-weight: 600;
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding-bottom: 10px;
      border-bottom: 2px solid #eeeeee;
      box-sizing: border-box;
    }
  }
}
.auditWrap{
  display: flex;
  justify-content: end;
}
</style>
